/*
	Copyright 2006, 2007, 2008, 2009, 2010 Bastiaan Grutters
    
    This file is part of Ages of Strife website.

    Ages of Strife website is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Ages of Strife website is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Ages of Strife website.  If not, see <http://www.gnu.org/licenses/>.
 */
// Define the main namespace
AOS = function() {};
AOS = AOS.prototype = function() {};

// Define utils
AOS.utils = function() {};
AOS.utils = AOS.utils.prototype= function() {};

AOS.utils.namespace = function( sName ) {
	var namespaces = sName.split('.') || [sName];
	var nlen = namespaces.length;
	var root = window;
	var F = function() {};
	for(var i = 0; i < nlen; i ++ ) {
		var ns = namespaces[i];
		if( typeof( root[ns] ) === 'undefined' ) {
			root = root[ns] = F;
			root = root.prototype = F;
		}
		else {
			root = root[ns];
		}
	}
}

AOS.utils.initializeMedals = function() {
	if( YAHOO.env.ua.ie == 0 ) {
		var medals = YAHOO.util.Dom.getElementsByClassName( "medal", "div" );
		var medalTooltips = Array();
		
		for( var i in medals ) {
			var img = medals[i].getElementsByTagName( "img" );
			if( img[0] && img[0].alt && img[0].alt != "" ) {
				medalTooltips = new YAHOO.widget.Tooltip( "medal[" + i + "]", {
					context: img[0], 
					autodismissdelay: 999999, 
					showDelay: 250, 
					preventoverlap: true, 
					text: "" + img[0].alt } );
			}
		}
	}
}

AOS.utils.selectAllNotifications = function() {
	var notifications = YAHOO.util.Dom.getElementsByClassName( "notification-checkbox", "input" );
	for( var i in notifications ) {
		notifications[i].checked = true;
	}
} 

YAHOO.util.Event.addListener( window, "load", AOS.utils.initializeMedals );